import request from "./request";

interface LoginParamsType {
  password: string;
  username: string;
}

interface LoginResultType {
  token: string;
  tokenHead: string;
}

interface AdminResultType {
  menus: MenuType[]; //number[]
}

interface AdminListRes {
  list: AdminListType[];
  total: number;
}

export interface AdminListType {
  createTime: string;
  email: string;
  icon: string;
  id: number;
  loginTime: string;
  nickName: string;
  note: string;
  password: string;
  status: 0 | 1;
  username: string;
}

//登录接口
export const adminLogin = (
  data: LoginParamsType
): PromiseResType<LoginResultType> => request.post("/admin/login", data);

//获取用户信息数据
export const getAdminInfo = (): PromiseResType<AdminResultType> =>
  request.get("/admin/info");

//获取用户列表
export const getAdminList = (
  data: AdminListParams
): PromiseResType<AdminListRes> => request.get("/admin/list", { params: data });
